package com.bsdk.install.device.electricmeter.v1.cmd;

/**
 * @ProjectName: com.hlslock.utils.lock
 * @Package: com.hlslock.utils.lock
 * @ClassName: ICmd
 * @Author: HansYoung
 * @Description: cmd
 * @Createtime: 2023/12/11 08:40
 * @Modifytime: 2023/12/14 20:44
 * @Version: 1.0
 * @Copyright: ©2006-2023 版权所有. 深圳豪力士
 */
public interface ICmd {
    public static final String VERSION = "V1.0.0";

    /**
     * 返回指令常量
     */
    public static final int STATUS_SUCCESS = 200; //请求正确，如开锁，下发各类指令

    public static final int STATUS_ERROR = 500; //指令错误
    //


    //接收状态 2007规约
    public final int CMD_RECEIVE_HEAD = 0x00;
    public final int CMD_RECEIVE_METER_SN = 0x01;
    public final int CMD_RECEIVE_HEAD_2 = 0x02;
    public final int CMD_RECEIVE_CMD = 0x03;
    public final int CMD_RECEIVE_LEN = 0x04;
     public final int CMD_RECEIVE_CMD_DATA = 0x05;
    public final int CMD_RECEIVE_CRC = 0x06;
    public final int CMD_RECEIVE_TAIL = 0x07;
    public final int CMD_RECEIVE_OK = 0x08;

    public static final byte  METER_TOTOAL_VAL_RESP = (byte) 0x91;

    //以下是网关的注册
    public static final byte  CHILD_SET_MASTER_ADDR_CMD = (byte) 0x7E; //注册模块
    public static final byte  CHILD_REQ_MASTER_ADDR_CMD = (byte) 0x7F; //查询模块注册


    //模块的通讯协议
    public final int MOUDLE_CMD_RECEIVE_HEAD = 0x00;
    public final int MOUDLE_CMD_RECEIVE_LEN1 = 0x01;
    public final int MOUDLE_CMD_RECEIVE_LEN2 = 0x02;
    public final int MOUDLE_CMD_RECEIVE_CMD_DATA = 0x04;
    public final int MOUDLE_CMD_RECEIVE_CRC = 0x05;
    public final int MOUDLE_CMD_RECEIVE_TAIL = 0x06;
    public final int MOUDLE_CMD_RECEIVE_OK = 0x07;


    public final byte MOUDLE_CMD_REGIST_RESP = (byte) (0x77+0x80);//Regist 指令
    public final byte MOUDLE_CMD_PING_RESP = (byte) (0x78+0x80);//ping 指令
    public final byte MOUDLE_CMD_SET_REGIST_RESP = (byte) (0x7E+0x80);//Regist 指令
    public final byte MOUDLE_CMD_REQ_PING_RESP = (byte) (0x7F+0x80);//查询

    /**
     * 网关协议
     * @param byteData
     * @param len
     * @return
     */
    byte check_crc(byte[] ptr, int n);
    public  String pack_crc(byte[] data, int len);
    public  String pack_Meter_checksum(byte[] data, int len);

    byte[] toBytes(String s);

}